;(function () {
  function scaleScreen(e, flag) {
    var
      w = ((__ANOV__PUBLIC__CONFIG &&
        __ANOV__PUBLIC__CONFIG.pageSize &&
        __ANOV__PUBLIC__CONFIG.pageSize.width) ||
        1920)
      h = ((__ANOV__PUBLIC__CONFIG &&
        __ANOV__PUBLIC__CONFIG.pageSize &&
        __ANOV__PUBLIC__CONFIG.pageSize.width) ||
        1080)
    let dw = document.body.clientWidth
    let dh = document.body.clientHeight
      i = Math.min(
        dw / w,
        dh / h
      )
    e.style.width = w + 'px'
    e.style.height = h + 'px'
    e.style.transform = 'scale(' + i + ')'
    e.style.top = (dh - h) / 2 + "px"
    e.style.left = (dw - w) / 2 + "px"
  }
  var dom1 = document.getElementById('appLoadingWrapper')

  scaleScreen(dom1, true)

  window.onresize=function(){
    scaleScreen(dom1)
  };
  function resize() {
    let wrap = document.querySelector(this.wrapSelector)
    let view = document.querySelector(this.domSelector)
    if (!(wrap && view)) return
    view.style.position = "absolute"
    view.style.width = this.w + "px"
    view.style.height = this.h + "px"
    let dw = this.wrapSelector ? wrap.clientWidth : document.body.clientWidth
    let dh = this.wrapSelector ? wrap.clientHeight : document.body.clientHeight
    let minRatio = Math.min(dw / this.w, dh / this.h)
    let left, top, right, bottom

    view.style.transform = "scale(" + minRatio + ")"
    top = (dh - this.h) / 2 + "px"
    left = (dw - this.w) / 2 + "px"

    top ? (view.style.top = top) : (view.style.bottom = bottom)
    left ? (view.style.left = left) : (view.style.right = right)
  }
  // 判断浏览器及版本
  let browserInfo = getBrowser()
  let browserArr = [
    { key: 'chrome', version: '80.0.0.0', name: 'chrome' },
    { key: 'firefox', version: '95.0', name: '火狐' },
    { key: 'qqbrowser', version: '10.8.0.0', name: 'QQ' },
    { key: 'edge', version: '80.0.0.0', name: 'Edge' },
    { key: 'sougu', version: '70.0.0.0', name: '搜狗' },
    { key: '360ee', version: '70.0.0.0', name: '360极速' },
    { key: 'safari', version: '15.0.0.0', name: 'safari' }
  ]

  let showHelp = false,
    showVersionHelp = false,
    cur_browser = ''
  for (let i = 0; i < browserArr.length; i++) {
    if (browserInfo.name.toLowerCase().indexOf(browserArr[i].key) > -1) {
      showHelp = false
      cur_browser = browserArr[i]
      let cur_version = browserInfo.version.split('.'),
        ask_version = browserArr[i].version.split('.')
      for (let j = 0; j < cur_version.length; j++) {
        if (cur_version[j] - 0 < ask_version[j] - 0) {
          showVersionHelp = true
          break
        }
        if (
          j === cur_version.length - 1 &&
          cur_version[j] - 0 === ask_version[j] - 0
        ) {
          showVersionHelp = false
        }
      }
    }
  }
  if (showHelp) {
    help(
      '当前非谷歌、火狐、QQ、360极速、Edge、搜狗浏览器，请切换至以上任一浏览器查看！'
    )
  }
  if (showVersionHelp) {
    help(
      `当前浏览器为${cur_browser.name}，版本${browserInfo.version}，要求该浏览器版本至少为${cur_browser.version}, 请升级您的浏览器！`
    )
  }
  function help(e) {
    let t =
      `<style>.sys-warn{position:fixed;top:0;left:0;display:flex;justify-content:center;align-items:center;width:100%;height:100%;background:#e73;color:#fff;font-size:26px;padding:0 20%;flex-direction:column;box-sizing:border-box;z-index:120210829}.a-wrap{text-align:right;width:100%}.sys-warn-a{text-decoration:none;color:antiquewhite;font-size:14px;position:relative}.sys-warn-a::after{content:'';display:block;width:100%;height:1px;background:#fff;position:absolute;bottom:-2px;transition:all .3s;transform:scaleX(0);transform-origin:left;left:0}}.sys-warn-a:hover{color:#fff}.sys-warn-a:hover::after{transform:scaleX(1)}</style>` +
      '<div class="sys-warn"><p>' +
      e +
      '</p><div class="a-wrap"><a class="sys-warn-a" href="mailto:zhu18@vip.qq.com?subject=' +
      encodeURI('anov可视化平台:[' + e + ']') +
      '&body=%E5%A6%82%E6%9E%9C%E5%9B%9E%E5%A4%8D%E4%B8%8D%E5%8F%8A%E6%97%B6%E8%AF%B7%E8%81%94%E7%B3%BB:%E6%9C%B1%E6%B6%A6%E4%BA%9A%2018610279719">[我不明白,我需要帮助]</a></div></div>'
    document.write(t)
  }

  function getBrowser() {
    var UserAgent = navigator.userAgent.toLowerCase()
    var browser = null
    var browserArray = {
      Chrome:
        UserAgent.indexOf('chrome') > -1 && UserAgent.indexOf('safari') > -1, // Chrome浏览器
      Firefox: UserAgent.indexOf('firefox') > -1, // 火狐浏览器
      Safari:
        UserAgent.indexOf('safari') > -1 && UserAgent.indexOf('chrome') == -1, // safari浏览器
      Edge: UserAgent.indexOf('edge') > -1, // Edge浏览器
      QQBrowser: /qqbrowser/.test(UserAgent), // qq浏览器
      Sougou: UserAgent.indexOf('se') > -1, //搜狗浏览器
      '360jisu': UserAgent.indexOf('360ee') > -1 //360极速浏览器
    }
    for (var i in browserArray) {
      if (browserArray[i]) {
        var versions = ''
        if (i == 'Chrome') {
          for (var mt in navigator.mimeTypes) {
            //检测是否是360浏览器(测试只有pc端的360才起作用)
            if (
              navigator.mimeTypes[mt]['type'] == 'application/360softmgrplugin'
            ) {
              i = '360'
            }
          }
          versions = UserAgent.match(/chrome\/([\d.]+)/)[1]
        } else if (i == 'Firefox') {
          versions = UserAgent.match(/firefox\/([\d.]+)/)[1]
        } else if (i == 'Safari') {
          versions = UserAgent.match(/version\/([\d.]+)/)[1]
        } else if (i == 'Edge') {
          versions = UserAgent.match(/edge\/([\d.]+)/)[1]
        } else if (i == 'QQBrowser') {
          versions = UserAgent.match(/qqbrowser\/([\d.]+)/)[1]
        } else if (i == 'Sougou') {
          versions = UserAgent.match(/chrome\/([\d.]+)/)[1]
        } else if (i == '360jisu') {
          versions = UserAgent.match(/chrome\/([\d.]+)/)[1]
        }
        browser = {
          name: i,
          version: versions
        }
      }
    }
    return browser
  }

  ;/^file/gi.test(window.location.href) && help('请配置web服务器进行浏览！')
})()
